﻿$(function () {
    $('#btnNext').click(function () {
        //var email = $('#txtEmail').val();
        //if (email == "") {
        //    toastr.warning("邮箱账号不能为空!");
        //    return false;
        //}

        //var regEmail = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
        //var reg = new RegExp(regEmail);
        //if (!reg.test(email)) {
        //    toastr.warning("邮箱格式不正确!");
        //    return false;
        //}
        var account = $('#txtAccount').val();

        var password = $('#txtPassword').val();
        if (password == "") {
            toastr.warning("密码不能为空!");
            return false;
        }

        var regPwd = /^[\w_-]{6,16}$/;
        var reg = new RegExp(regPwd);
        if (!reg.test(password)) {
            toastr.warning("密码规则不符合要求!");
            return false;
        }

        $.ajax({
            type: "post",
            url: PSIRoot + 'PSIUser/SavePassword',
            //data: { email: email, password: password },
            data: { account: account, password: password },
            success: function (data) {
                if (data.SubmitResult) {
                    $('[name="step1"]').hide();
                    $('[name="step2"]').show();
                } else {
                    dialog.danger('操作失败！Error Message:' + data.Message);
                }
            },
            error: function () {
                dialog.danger('操作失败！请重试或者联系管理员');
            },
            complete: function () {

            }
        });

    });
})
